
import Vue from 'vue'
import { Api } from '../../api/api'
import { ApiCall } from '../../api/apiService'

Vue.prototype.$LoginService = {
    login: function (option) {
        ApiCall({
            api: Api.login,
            param: {
                'requestParam': {
                    'data': {
                        type: option.param.loginType,
                        phone: option.param.phone,
                        password: option.param.password,
                        captcha: option.param.verifyCode
                    }
                }
            },
            success: (res) => {
                let responseState = res.responseData.responseState
                if (responseState.code === 0) {
                    option.success && option.success(res.responseData)
                } else {
                    option.error && option.error(res)
                }
            },
            error: (res) => {
                option.error && option.error(res)
            }
        })
    }
}
